{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6a768065",
   "metadata": {},
   "source": [
    "* 2023-12-11\n",
    "* 课程：Python语言\n",
    "* week14"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1c0c2f48",
   "metadata": {},
   "source": [
    "# 1. 创建Flask最小应用"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "409997e1",
   "metadata": {},
   "source": [
    "> 1. 传递一个文本到指定的路由URL界面\n",
    "> 2. 传递一个HTML的文本信息到指定路由URL界面\n",
    ">> 1. 思考：如果\"return HTML的代码\" 会显得HTML代码很多，且写在了Python文件当中；\n",
    ">> 2. 思考：如果前（HTML）后（Python）端可以分开两个文件（前后端分离）就比较好了；\n",
    ">> 3. 结论：使用render_template方法实现前后端分离"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "97a99761",
   "metadata": {},
   "outputs": [],
   "source": [
    "from flask import Flask\n",
    "app = Flask(__name__)\n",
    "\n",
    "@app.route('/')\n",
    "def hello_world():\n",
    "    return 'Hello, World!'\n",
    "\n",
    "@app.route('/index')\n",
    "def index():\n",
    "    return '<h1 >期末100分<h1>'\n",
    "\n",
    "app.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3a96607e",
   "metadata": {},
   "outputs": [],
   "source": [
    " * Serving Flask app '__main__'\n",
    " * Debug mode: off\n",
    "WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.\n",
    " * Running on http://127.0.0.1:5000\n",
    "Press CTRL+C to quit\n",
    "127.0.0.1 - - [11/Dec/2023 20:01:07] \"GET / HTTP/1.1\" 200 -\n",
    "127.0.0.1 - - [11/Dec/2023 20:01:13] \"GET /index HTTP/1.1\" 200 -"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e357480a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
